#ifndef BASE_CTNETSERVICE_H_
#define BASE_CTNETSERVICE_H_

#include "ct_service.h"
#include "ct_tcp_srv.h"

class ctNetService:
        public ctService
{
        public:
                virtual ~ctNetService() { instance_ = NULL; }
                virtual void newTCPTask(const int sock, const struct sockaddr_in *addr) = 0;
                virtual const int getPoolSize() const { return 0; }
                virtual const int getPoolState() const { return 0; }

        protected:
                ctNetService(const std::string &name)
                        : ctService(name)
                {
                        instance_ = this;
                        service_name_ = name;
                        tcp_server_ = NULL;
                }
                bool init(unsigned short port);
                bool serviceCallBack();
                void final();

        public:
                ctTCPServer *tcp_server_;	

        private:
                static ctNetService *instance_;
                std::string service_name_;
};

#endif //BASE_CTNETSERVICE_H_

